package com.stylefeng.guns.modular.system.warpper;

import com.stylefeng.guns.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.common.constant.state.Status;
import com.stylefeng.guns.common.persistence.model.Dict;
import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.ToolUtil;

import java.util.List;
import java.util.Map;

/**
 * 字典列表的包装
 *
 * @author fengshuonan
 * @date 2017年4月25日 18:10:31
 */
public class DictWarpper extends BaseControllerWarpper {

    public DictWarpper(Object list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
        map.put("statusName", Status.valueOf((Integer) map.get("status")));
        StringBuffer detail = new StringBuffer();
        //Integer id = (Integer) map.get("id");
        //List<Dict> dicts = ConstantFactory.me().findDictByPID(id);
        //if (dicts != null) {
        //    for (Dict dict : dicts) {
        //        detail.append(dict.getNum() + ":" + dict.getName() + (dict.getTips() == null ? "" : dict.getTips()) + ",");
        //    }
        //    map.put("detail", ToolUtil.removeSuffix(detail.toString(), ","));
        //}
    }

}
